Expand description
§text-document
A rich text document model for Rust.
Provides a TextDocument as the main entry point and TextCursor for
cursor-based editing, inspired by Qt’s QTextDocument/QTextCursor API.
use text_document::{TextDocument, MoveMode, MoveOperation};
let doc = TextDocument::new();
doc.set_plain_text("Hello world").unwrap();
let cursor = doc.cursor();
cursor.move_position(MoveOperation::EndOfWord, MoveMode::KeepAnchor, 1);
cursor.insert_text("Goodbye").unwrap(); // replaces "Hello"
// Multiple cursors on the same document
let c1 = doc.cursor();
let c2 = doc.cursor_at(5);
c1.insert_text("A").unwrap();
// c2's position is automatically adjusted
doc.undo().unwrap();Structs§
- Block
Format - Block (paragraph) formatting. All fields are optional.
- Block
Info - Info about a block at a given position.
- Block
Snapshot - All layout-relevant data for one block, captured atomically.
- Cell
Format - Cell-level formatting.
- Cell
Snapshot - Snapshot of one table cell including its block content.
- Document
Fragment - A piece of rich text that can be inserted into a
TextDocument. - Document
Stats - Document-level statistics. O(1) cached.
- Docx
Export Result - Result of a DOCX export (
to_docx). - Find
Match - A single search match.
- Find
Options - Options for find / find_all / replace operations.
- Flow
Snapshot - Consistent snapshot of the entire document flow, captured in a single lock acquisition.
- Frame
Format - Frame formatting. All fields are optional.
- Frame
Snapshot - Snapshot of a sub-frame and its contents.
- Html
Import Result - Result of an HTML import (
set_html). - List
Info - List membership and marker information for a block.
- Markdown
Import Result - Result of a Markdown import (
set_markdown). - Operation
- A handle to a running long operation (Markdown/HTML import, DOCX export).
- Subscription
- Handle to a document event subscription.
- Table
Cell Ref - Reference to a table cell that contains a block.
- Table
Format - Table-level formatting.
- Table
Snapshot - Consistent snapshot of a table’s structure and all cell content.
- Text
Block - A lightweight, read-only handle to a single block (paragraph).
- Text
Cursor - A cursor into a
TextDocument. - Text
Document - A rich text document.
- Text
Format - Character/text formatting. All fields are optional:
Nonemeans “not set — inherit from the block’s default or the document’s default.” - Text
Frame - A read-only handle to a frame in the document.
- Text
List - A read-only handle to a list in the document.
- Text
Table - A read-only handle to a table in the document.
- Text
Table Cell - A read-only handle to a single cell within a table.
Enums§
- Alignment
- Cell
Vertical Alignment - Vertical alignment within a table cell.
- Char
Vertical Alignment - Document
Event - Events emitted by a
TextDocument. - Flow
Element - An element in the document’s visual flow.
- Flow
Element Snapshot - Snapshot of one flow element.
- Format
Change Kind - What kind of formatting changed.
- Fragment
Content - A contiguous run of content with uniform formatting within a block.
- Frame
Position - Inline
Content - List
Style - Marker
Type - Move
Mode - Controls whether a movement collapses or extends the selection.
- Move
Operation - Semantic cursor movement operations.
- Resource
Type - Selection
Type - Quick-select a region around the cursor.
- Text
Direction - Underline
Style - Wrap
Mode